<?php
/**
* 
*/
class ClubsModel extends Model {
	public function __construct() {
			parent::Model();
			$this->load->model("LocationsModel");
		}
	public function getClubId($clubName) {
			$clubId = null;
			$rs = $this->db->query("SELECT club_id FROM clubs WHERE cName=?",$clubName);
			if($rs->num_rows()>0){
					$clubId = $rs->result()->club_id;
				}
			return $clubId;
		}
	public function create($clubDataArray,$contactDataArray,$locDataArray,$now) {
			$query = $this->db->insert_string("clubs",$clubDataArray);
			$this->db->query($query); // create club
			if($locDataArray!=null) {
					if($locId = $this->LocationsModel->getLocation($locDataArray["name"])) {
						// update club with location
						}
				}
		}
	public function closeClub($clubId) {
		
		}
	public function update($clubDataArray,$contactDataArray,$locDataArray,$now){
			$where = "cName = " . $clubDataArray["cName"];
			$query = $this->db->update_string('clubs', $clubDataArray, $where);
		}
	public function getClubsList() {
			$query = $this->db->get("clubs");
			return $query;
		}
}
?>